<%--
*
* 描述：公共头文件
*
--%>
<%@ page language="java" pageEncoding="UTF-8"%>
<%@page errorPage="/error/errorPage.jsp"%>
<jsp:directive.page import="com.toncen.samepms.basic.domain.User"/>
<jsp:directive.page import="com.toncen.samepms.basic.domain.Organization"/>
<jsp:directive.page import="com.toncen.samepms.system.domain.SkinConfiguration"/>
<jsp:directive.page import="com.toncen.samepms.common.AbstractAction"/>
<jsp:directive.page import="com.sky.common.filter.SecurityFilter"/>
<jsp:directive.page import="com.toncen.samepms.util.ErrorUtils"/>
<jsp:directive.page import="com.toncen.samepms.common.ComitConstant"/>
<jsp:directive.page import="com.toncen.samepms.system.dao.ConfigurationDao" />
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"+ request.getServerName() + ":" + request.getServerPort()+ path + "/";
	//从cookies里拿到用户的个性化设置
	SkinConfiguration skinCon =SkinConfiguration.getSkinConfigurationFromCookies(request);
	if(session.getAttribute(AbstractAction.SKIN_CONFIGURATION_SESSION_ATTRIBUTE)==null){//session中不存在，则放入session中
		session.setAttribute(AbstractAction.SKIN_CONFIGURATION_SESSION_ATTRIBUTE, skinCon);
	}
	ErrorUtils.setHandlerURL(request,response);//将当前处理页面地址放入request中，出错的时候错误日志记录的时候需要使用，不然记录错如日志会报错
%>
<%!
	User getCurrentUser(HttpSession session) throws Exception{//获取当前登录用户，没有登录则返回实例化的一个对象
		User user = (User) session.getAttribute(ComitConstant.USER_SESSION_ATTRIBUTE);
		if (user == null) {
			user= new User();
		}
		return user;
	}
	Organization getCurrentOrganization(HttpSession session) throws Exception{//获取当前登录用户的组织，没有登录或者没有组织则返回实例化的一个对象
		User user = getCurrentUser(session);
		Organization organization;
		if (user != null && user.getOrganization() != null) {
			organization= user.getOrganization();
		} else {
			organization=new Organization();
		}
		return organization;
	}%>
<%--支持ie8--%>
<%--<meta http-equiv="x-ua-compatible" content="ie=7" /> 	--%>
<%--<meta http-equiv="x-ua-compatible" content="IE=7" /> 	--%>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />	
<%--<script type="text/javascript" src="<%=path%>/js/jquery-1.7.1.min.js"></script>--%>
<script type="text/javascript" src="<%=path%>/js/jQuery.v1.4.2.min.js"></script>
<script type="text/javascript" src="<%=path%>/js/jquery.blockUI.min.js"></script>
<script type="text/javascript" src="<%=path%>/js/comit.common.min.js"></script>
<script type="text/javascript" src="<%=path%>/watermark/jquery.watermark.min.js"></script>
<script type="text/javascript" src="<%=path%>/easylinkage/EasyLinkage.min.js"></script>
<script type="text/javascript" src="<%=path%>/easytabs/EasyTabs.min.js"></script>
<script type="text/javascript" src="<%=path%>/js/jQuery.FillOptions.min.js"></script>
<script type="text/javascript" src="<%=path%>/js/jquery.ba-resize.min.js"></script>
<script type="text/javascript" src="<%=path%>/easyvalidator/js/config.min.js"></script>
<script type="text/javascript" src="<%=path%>/easyvalidator/js/EasyValidator.min.js"></script>
<script language="javascript" type="text/javascript" src="<%=path%>/my97datepicker/WdatePicker.js"  defer="defer"></script>
<link rel="stylesheet" type="text/css" href="<%=path%>/easyvalidator/css/validate_default.min.css">
<link rel="stylesheet" type="text/css" href="<%=path%>/easytabs/EasyTabs.min.css">
<link rel="stylesheet" type="text/css" href="<%=path%>/css/comit.common.min.css"/>
<link rel="shortcut icon" href="<%=path%>/favicon.ico" />
<%if(ComitConstant.isDeveloperMode()){//开发期引入，方便直接敲击路径就可以使用 %>
	<%@include file="/share/window.jsp"%>
<%}%>
<script>
  var contextPath="<%=path%>";//项目路径
  var basePath="<%=basePath%>";//项目根路径
  var systemTitle="<%=new ConfigurationDao().getValueByName("system_title")%>";//系统标题
  try{//ajax增加加载提示
  	$.blockUI.defaults.message='<br><br><img src="<%=path%>/image/loading.gif" ><br>我正在努力处理中，请耐心等待...<br><br>';
  	$.blockUI.defaults.css.backgroundColor='#000';
 	$.blockUI.defaults.css.color='#fff';
 	$.blockUI.defaults.overlayCSS.opacity='0.5';
 	$.blockUI.defaults.baseZ=2147483647;
	$.blockUI.defaults.timeout=30000;//超过30秒则自动关闭加载提示 	
  	//$(document).ajaxStart($.blockUI).ajaxStop($.unblockUI);
  }catch(e){}
  //屏蔽一些特殊键
  document.onkeydown=function (){
    try{
    	//alert(event.keyCode+":"+event.srcElement.tagName+"="+event.srcElement.type);
	    //屏蔽非输入框的退格键
	    if(event.keyCode==8){
	    	 //alert(event.keyCode+":"+event.srcElement.disabled +"|"+event.srcElement.readOnly);
	         if(event.srcElement.tagName=="TEXTAREA" || event.srcElement.tagName=="INPUT"){//多行 或者 单行 文本框
	          	 if(event.srcElement.disabled ||event.srcElement.readOnly){//禁用 或者 只读
		          	 //alert("符合文本输入框禁用 或者 只读...");	
			         event.keyCode=0; 
			         event.returnValue=false; 
			         return false;
		         }
	         }else{
	          	 //alert("符合非文本输入框...");	
		         event.keyCode=0; 
		         event.returnValue=false; 
		         return false;	         
	         }    
	    } 
	    //alert(window.event.altKey+":"+window.event.keyCode);
		//屏蔽   Alt+   方向键   ←   屏蔽   Alt+   方向键   →
		if((window.event.altKey)&&((window.event.keyCode==37)||(window.event.keyCode==39))) {  
			//alert("符合Alt+   方向键   ←   屏蔽   Alt+   方向键   →...");	   
			event.returnValue=false;
			return false;
		}   
		//alert(event.ctrlKey+":"+event.keyCode);	
		//屏蔽   Ctrl+n     
		if((event.ctrlKey)&&(event.keyCode==78)){
		  //alert("符合Ctrl+n...");	
		  event.returnValue=false;  
		  return false;   
		}	
    }catch(e){}   
  }
    //屏蔽非法内容，替换为空
  document.onkeyup=function (){
    try{  
		var srcElement=event.srcElement;
		if(srcElement!=null){
			if(srcElement.value!=null){
			  var testPatterm=/^.*?<script.*?\s*>.*?<\/script\s*>.*?$/gi;
			  var illegalPatterm=/<script.*?\s*>.*?<\/script\s*>/gi;
			  //alert(srcElement.value);
			  if(testPatterm.test(srcElement.value)){
			    //srcElement.select();
			    srcElement.style.backgroundColor  = "red";
			    srcElement.focus();
				var source=srcElement.value;
				var illegal=source.match(illegalPatterm)[0];
				var target=source.replace(illegalPatterm,"");			    
				alert("内容中包含非法内容，系统将自动清除非法内容，非法内容如下：\n【"+illegal+"】");
				srcElement.value=target;
				srcElement.select();
				srcElement.style.backgroundColor = "";
				srcElement.focus();
			  }	
			}
		}      	
    }catch(e){} 
  } 
<%
 //非法操作：直接在浏览器中敲URL操作数据，则跳转到非法操作提示页面(页面不在排除的页面中，并且不是允许的页面)
 if(!ComitConstant.isDeveloperMode()){//非开发模式才需要控制非法操作
  	if(!SecurityFilter.isExclusiveURI(ComitConstant.USER_SESSION_ATTRIBUTE,request)){//当前页面不是排除的页面
%>
		    if(top.publicPage==null||!top.publicPage){//当前页面不是允许的公开页面则跳到非法提示页面
		    	//alert(top.publicPage+":<%=request.getRequestURI()%>");
				document.location.replace("<%=path%>/share/unpermission.jsp?type=<%=SecurityFilter.class.getName()%>");
			}
<%
  	}
 }
%>  
</script>